package com.project.estate.chargeitem.controller;

import com.project.estate.chargeitem.service.ChargeItemService;
import com.project.estate.commons.bean.ChargeItem;
import com.project.estate.commons.config.JsonResult;
import com.project.estate.commons.config.ResultTool;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/changeitem")
public class ChangeItemController {

    @Resource
    private ChargeItemService chargeItemService;



    //添加数据
    @PostMapping("/add_change_item")
    public JsonResult addchangeitem(ChargeItem chargeItem){
        return chargeItemService.addChargeItem(chargeItem);
    }

    //修改数据
    @PutMapping("/update_change_item/{com_id}")
    public JsonResult updateChargeItem(ChargeItem chargeItem, @PathVariable("com_id") String com_id){
        return chargeItemService.updateChargeItemById(com_id,chargeItem);
    }

    //删除数据
    @DeleteMapping("/delete_change_item/{com_id}")
    public JsonResult deleteChargeItem(ChargeItem chargeItem,@PathVariable("com_id") String com_id){
        return chargeItemService.deleteChargeItemById(com_id,chargeItem);
    }

    //查询
    @GetMapping("/find_change_item_byId/{com_id}")
    public JsonResult findChargeItemById(@PathVariable("com_id") String com_id){
        return chargeItemService.findChargeItemByChargeItemId(com_id);
    }
}
